Repository Public
1// Auteur : Simon-Pierre Boucher — contact@spboucher.ai2// Analyse IA du bâtiment d'une annonce : photos → profil technique (Claude Sonnet 5)3// → assemblages → coûts actuels → méthode du coût. Déclenchée sur demande seulement.4import type { Metadata } from "next";5import { notFound } from "next/navigation";6import { getListing } from "@/lib/immoka";7import { getLatest } from "@/lib/cost/ai/service";8import { moneyFr } from "@/lib/seo";9import AiCostAnalysis, { type AiHead } from "@/components/avendre/cost/AiCostAnalysis";1011export const dynamic = "force-dynamic";1213function head(uid: string): AiHead | null {14 const det = getListing(uid);15 if (!det) return null;16 const l = det.listing;17 return {18 uid: l.uid, address: l.address, city: l.city, propertyType: l.property_type, price: l.price, images: det.images, source: l.source, yearBuilt: l.year_built, areaSqft: l.area_sqft,19 unitId: det.eval?.unit_id ?? null, evalEst: det.eval?.est ?? null, modelEst: det.eval?.model_est ?? null, compsEst: det.eval?.comps_est ?? null, roleValue: det.eval?.valeur_role ?? null,20 maxImages: Number(process.env.PROPERTY_ANALYSIS_MAX_IMAGES ?? 40), model: process.env.PROPERTY_ANALYSIS_MODEL ?? "claude-sonnet-5",21 };22}2324export async function generateMetadata({ params }: { params: Promise<{ uid: string }> }): Promise<Metadata> {25 const { uid } = await params;26 const h = head(decodeURIComponent(uid));27 if (!h) return { title: "Propriété introuvable" };28 const where = [h.address, h.city].filter(Boolean).join(", ");29 return { title: `Analyse IA du bâtiment — ${where} (${moneyFr(h.price)})`, description: "Des photos à la méthode du coût : l'IA transforme une annonce réelle en profil technique de bâtiment ; les coûts actuels du marché sont ensuite appliqués composante par composante.", robots: { index: false, follow: false } };30}3132export default async function Page({ params }: { params: Promise<{ uid: string }> }) {33 const { uid } = await params;34 const h = head(decodeURIComponent(uid));35 if (!h) notFound();36 const initial = getLatest(h.uid);37 return <AiCostAnalysis head={h} initial={initial} />;38}39